package com.baizhi.service.impl;

import com.baizhi.dao.CityDao;
import com.baizhi.entity.City;
import com.baizhi.service.CityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CityServiceImpl implements CityService {
    @Autowired
    private CityDao cityDao;
    @Override
    public void insert(City city) {
        cityDao.insert(city);
    }

    @Override
    public void delete(Integer id) {
        cityDao.delete(id);
    }

    @Override
    @Transactional(readOnly = true)
    public PageInfo<City> selectByPage(String name, Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        PageInfo<City> pageInfo = new PageInfo<>(cityDao.selectByPage(name));
        return pageInfo;
    }
}
